<!--
  #%L
  thinkbig-ui-operations-manager
  %%
  Copyright (C) 2017 ThinkBig Analytics
  %%
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
      http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  #L%
  -->
    <div flex layout="row" layout-sm="column" layout-xs="column">
            <card-layout flex="100" flex-gt-sm="80" flex-order="1" flex-order-xs="2" flex-order-sm="2" >
                <header-section style="white-space:nowrap" transclude-to="head" class="card-title">调度作业</header-section>

                <body-section>
                <md-list flex layout-fill transclude-to="body" class="list-item-table">
                    <md-list-item  ng-repeat="job in vm.jobs | orderBy:'jobName'" layout="row">

                            <div flex="25" layout="column" class="item-column md-list-item-text ">
                                     <span class="item-title">
                                       {{job.jobName}}
                                     </span>
                                      <span ng-class="{'healthy': job.state == 'RUNNING' || job.state == 'SCHEDULED', 'warn':job.state == 'PAUSED', 'error':job.state == 'UNKNOWN'}" class="column-title-bottom">
                                         <ng-md-icon icon="{{job.stateIcon}}" size="20" options='{"rotation": "clock"}' >
                                         </ng-md-icon>   {{job.state|fstatus}}
                                    </span>


                            </div>
                            <div flex="10" layout="column" class="item-column md-list-item-text ">
                                   <span class="column-title column-title-bottom">
                                     组
                                   </span>
                                   <span  class="item-title" >
                                     {{job.jobGroup}}</span>

                            </div>
                            <div flex="20" layout="column" class="item-column md-list-item-text ">
                                <span class="column-title column-title-bottom">
                                     下次执行
                                   </span>
                                   <span  class="item-title" >
                                     {{job.nextFireTimeString}}
                                   </span>

                            </div>
                            <div flex="15" layout="column" class="item-column md-list-item-text " hide show-gt-md>
                                <span class="column-title column-title-bottom">
                                    Cron表达式
                                   </span>
                                   <span  class="item-title" >
                                     {{job.cronExpression}}</span>

                            </div>
                            <div flex="30" flex-md="45" flex-sm="45" flex-xs="45" layout="row" class="item-column md-list-item-text " ng-if="vm.allowAdmin">
                                <md-button class="border-btn" style="background-color: royalblue" ng-if="job.state=='RUNNING' || job.state =='SCHEDULED'" ng-disabled="job.state =='PAUSED' || job.state == 'RUNNING' || vm.schedulerDetails.status == 'PAUSED' " ng-click="vm.pauseJob(job)">暂停</md-button>
                                <md-button class="border-btn"  style="background-color: royalblue"  ng-if="job.state=='PAUSED'" ng-disabled="job.state =='RUNNING' || vm.schedulerDetails.status == 'PAUSED'" ng-click="vm.resumeJob(job)">恢复</md-button>
                                <md-button class="border-btn"style="background-color: royalblue" ng-disabled="job.state !='SCHEDULED' || vm.schedulerDetails.status == 'PAUSED'" ng-click="vm.triggerJob(job)">立即开启</md-button>
                            </div>

                        <md-divider ng-if="!$last"></md-divider>
                    </md-list-item>
                </md-list>
                </body-section>
            </card-layout>

            <card-layout flex-gt-sm="20" flex-order="2" flex-order-xs="1" flex-order-sm="1" >
                <header-section style="white-space:nowrap" transclude-to="head" class="card-title">调度详情</header-section>
                <body-section transclude-to="body" flex layout="column">
                    <div layout-align="center center" style="width:100%" ng-if="vm.allowAdmin">
                    <md-button class="border-btn" style="width:150px;max-width:150px;" ng-show="vm.schedulerDetails.status == 'RUNNING'" ng-click="vm.pauseScheduler()">
                        暂停调度
                    </md-button>
                    <md-button class="border-btn"  style="width:150px;max-width:150px;" ng-show="vm.schedulerDetails.status == 'PAUSED'" ng-click="vm.resumeScheduler()">
                       恢复调度
                    </md-button>
                    </div>


                    <md-list class="list-item-table" layout="column">
                        <md-list-item >
                            <div class="item-column md-list-item-text " layout-align="space-between start" layout="column">
                                      <span class="column-title column-title-bottom">
                                        状态
                                    </span>
                                    <span ng-class="{'healthy': vm.schedulerDetails.status == 'RUNNING', 'warn':vm.schedulerDetails.status == 'PAUSED'}">
                                         <ng-md-icon icon="{{vm.schedulerDetails.statusIcon}}" size="20" options='{"rotation": "clock"}'>
                                         </ng-md-icon>   {{vm.schedulerDetails.status|fstatus}}
                                    </span>

                            </div>
                        </md-list-item>
                        <md-divider></md-divider>
                        <md-list-item >
                            <div class="item-column md-list-item-text " layout-align="space-between start" layout="column">
                                <span class="column-title column-title-bottom">
                                     工作时间
                                </span>
                                    <span class="item-title">
                                        {{vm.schedulerDetails.upTime}}
                                    </span>

                            </div>
                        </md-list-item>
                        <md-divider></md-divider>
                        <md-list-item>
                            <div class="item-column md-list-item-text " layout-align="space-between start" layout="column">
                                  <span class="column-title column-title-bottom">
                                    开始时间
                                    </span>
                                 <span class="item-title">
                                      {{vm.schedulerDetails.startTime}}
                                    </span>
                                </div>
                        </md-list-item>
                        <md-divider></md-divider>
                        <md-list-item >
                            <div class="item-column md-list-item-text " layout-align="space-between start" layout="column">
                                  <span class="column-title column-title-bottom">
                                     执行的作业
                                    </span>
                                    <span class="item-title">
                                        {{vm.schedulerDetails.jobsExecuted}}
                                    </span>
                            </div>
                        </md-list-item>
                    </md-list>
                </body-section>
                </card-layout>
    </div>
